//
//  HJGoogleAuthenticator.m
//  GoogleLoginICloud
//
//  Created by lx on 2024/1/6.
//

#import "GoogleAuthenticator.h"
#import <GoogleAPIClientForREST/GTLRDrive.h>
#import "GoogleCloudStorage.h"

@implementation GoogleAuthenticator

+ (void)signInWithClientID:(nullable NSString *)clientID presentingViewController:(UIViewController *)presentingViewController completion:(void (^__nullable)(GIDGoogleUser *user, NSError *error))completion {
    
    
    [GIDSignIn.sharedInstance signInWithPresentingViewController:presentingViewController hint:nil additionalScopes:@[kGTLRAuthScopeDrive, kGTLRAuthScopeDriveFile] completion:^(GIDSignInResult * _Nullable signInResult, NSError * _Nullable error) {
        
        GoogleCloudStorage.driveService.authorizer = [GIDSignIn sharedInstance].currentUser.fetcherAuthorizer;
        
        NSLog(@"error = %@", error);

        if (completion) {
            completion(signInResult.user, error);
        }
        
    }];
    
    
}


@end
